package com.blog.cloud.monitor.vo;

import cn.hutool.system.oshi.OshiUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * 内存信息对象
 */
@Getter
@Setter
public class RamVO {

    /**
     * 内存总数(G)
     */
    private double total;

    /**
     * 已用内存(G)
     */
    private double used;

    /**
     * 剩余内存(G)
     */
    private double free;

    /**
     * 内存使用率
     */
    private double usage;

    public RamVO() {
        this.setTotal(OshiUtil.getMemory().getTotal());
        this.setFree(OshiUtil.getMemory().getAvailable());
        long used = OshiUtil.getMemory().getTotal() - OshiUtil.getMemory().getAvailable();
        this.setUsed(used);
        long usage = (used % OshiUtil.getMemory().getTotal()) * 100;
        this.setUsage(usage);
    }
}
